package com.lsw.shareUser;

import android.content.Context;

/**
 * 本地sp用户信息工具
 *
 * @author lsw
 */
public class ShareUserInfoUtil {

    private SharePrefHelper shareHelper;
    static ShareUserInfoUtil instance = null;
    // 类实例
    public static String ID = "id";// 用户id
    public static String GROUP_ID = "group_id";// 分组id
    public static String USERNAME = "username";// 用户昵称
    public static String USER_TOKEN = "user_token";// 用户token
    public static String MOBILE = "mobile";// 电话
    public static String PASSWORD = "password";//密码
    public static String IS_PUSH = "is_push";//1推送2不推送
    public static String CARD_URL = "card_url";//身份证照片
    public static String CARD_NUM = "card_num";//身份证号
    public static String SEX = "sex";// 性别
    public static String HEADPHOTO = "pic";// 头像
    public static String EMAIL = "email";//邮箱
    public static String SOURCE = "reg_source";//用户来源，安卓，ios，web
    public static String UPDATE = "update";//最后修改时间
    public static String CREATE_AT = "created_at";//注册时间
    public static String UPDATE_TIME = "update_time";
    public static String CREATE_TIME = "create_time";
    public static String TYPE = "type";
    public static String IMG_ID = "img_id";
    public static String STORE_ID = "store_id";

    public static String LAST_IP = "last_ip";//最后登录IP
    public static String STATUS = "status";
    public static String ADDRESS = "address";//详细地址
    public static String OPENID = "openid";//第三方openid
    public static String AUTHIMG = "authimg";//认证图片地址,此字段有值的时候通过authed判断状态
    public static String AUTHED = "authed";//0待审核 1审核成功 2审核失败
    public static String REG_PHONE_TYPE = "reg_phone_type";//注册手机
    public static String LOGIN_PHONE_TYPE = "login_phone_type";//登录手机


    public static String LOGIN = "login";// 用户登录次数
    public static String REG_IP = "reg_ip";// 注册IP
    public static String BIRTHDAY = "age";// 出生日期


    public static String CUSTOMER_PHONE = "customer_phone";// 客服手机号
    public static String CUSTOMER_WEIXIN = "customer_weixin";// 客服微信
    public static String CUSTOMER_EMAIL = "customer_email";// 客服邮箱
    public static String COMPANY_URL = "company_url";// 公司网址
    public static String STATION_DISTANCE = "station_distance";// 站点距离提醒
    public static String INVOICE_MONEY_MIN = "invoice_money_min";// 发票最低金额提醒
    public static String ADD_AIR_MONEY = "add_air_money";// 加气金额提醒
    public static String SHARE_REDBAGS = "share_redbags";//是否有分享活动
    public static String INVITE_CODE = "invite_code";//用户邀请码
    public static String DOMAIN_NAME = "domain_name";//切换域名 1表示正式环境，2表示测试环境


    /**
     * 应用版本号
     */
    public static final String SP_VERSION = "VERSION";

    public static ShareUserInfoUtil getInstance(Context context) {
        if (instance == null)
            instance = new ShareUserInfoUtil(context);
        return instance;
    }

    public ShareUserInfoUtil(Context context) {
        shareHelper = new SharePrefHelper(context,
                SharePrefHelper.SHARE_USERINFO);
    }

    /**
     * 获取
     *
     * @param key
     * @param defVal
     * @return
     */
    public String getString(String key, String defVal) {
        return shareHelper.getSharePre(key, defVal);
    }

    /**
     * 存储
     *
     * @param key
     * @param value
     */
    public void setString(String key, String value) {
        shareHelper.setSharePre(key, value);
    }

    /**
     * 获取
     *
     * @param key
     * @return
     */
    public boolean getBooble(String key, Boolean defVal) {
        return shareHelper.getSharePreBoolean(key, defVal);
    }

    /**
     * 存储
     *
     * @param key
     * @param value
     */
    public void setBooble(String key, Boolean value) {
        shareHelper.setSharePre(key, value);
    }

    /**
     * 获取
     *
     * @param key
     * @return
     */
    public int getInt(String key, int defVal) {
        return shareHelper.getSharePreInt(key, defVal);
    }

    /**
     * 存储
     *
     * @param key
     * @param value
     */
    public void setInt(String key, int value) {
        shareHelper.setSharePre(key, value);
    }

    /**
     * 清除用户缓存
     */
    public void clearCache() {
        setString(ID, "");
        setString(USERNAME, "");
        setString(MOBILE, "");
        setString(BIRTHDAY, "");
        setString(IS_PUSH, "");
        setString(CARD_URL, "");
        setString(CARD_NUM, "");
        setString(SEX, "");
        setString(PASSWORD, "");
        setString(HEADPHOTO, "");
        setString(EMAIL, "");
        setString(LOGIN, "");
        setString(REG_IP, "");
        setString(SOURCE, "");
        setString(STATUS, "");
        setString(UPDATE, "");
        setString(LAST_IP, "");
        setString(CREATE_AT, "");
        setString(UPDATE_TIME, "");
        setString(CREATE_TIME, "");
        setString(TYPE, "");
        setString(IMG_ID, "");
        setString(STORE_ID, "");
        setString(ADDRESS, "");
        setString(OPENID, "");
        setString(AUTHIMG, "");
        setString(AUTHED, "");
        setString(REG_PHONE_TYPE, "");
        setString(LOGIN_PHONE_TYPE, "");
        setString(USER_TOKEN, "");
        setString(GROUP_ID, "");
        setString(CUSTOMER_PHONE, "");
        setString(CUSTOMER_WEIXIN, "");
        setString(CUSTOMER_EMAIL, "");
        setString(COMPANY_URL, "");
        setString(STATION_DISTANCE, "");
        setString(INVOICE_MONEY_MIN, "");
        setString(ADD_AIR_MONEY, "");
        setString(SHARE_REDBAGS, "");
        setString(INVITE_CODE, "");
        setString(DOMAIN_NAME, "");

    }
}
